/*
 * @Author: your name
 * @Date: 2021-07-27 09:40:49
 * @LastEditTime: 2021-08-19 15:02:44
 * @LastEditors: GGB
 * @Description: In User Settings Edit
 * @FilePath: \flutter_faster_study\lib\screens\home\components\menus.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/model/common/menu_model.dart';
import 'package:flutter_data_center/utills/color_utils.dart';

class MenusPopup extends StatelessWidget {
  const MenusPopup(
      {Key key,
      @required this.onTap,
      @required this.level,
      @required this.menus})
      : super(key: key);
  final ValueChanged<String> onTap;
  final String level;
  final List<MenuModel> menus;

  @override
  Widget build(BuildContext context) => Container(
        width: 30,
        child: PopupMenuButton<String>(
          onSelected: onTap,
          icon: Icon(
            Icons.more_vert,
            color: Colors.black,
          ),
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 0),
          offset: Offset(0, 30),
          itemBuilder: (context) {
            return <PopupMenuEntry<String>>[
              ...menus
                  .map((menu) => PopupMenuItem<String>(
                        value: "${menu.key}",
                        child: Text(
                          menu.value,
                          style: TextStyle(
                            color: menu.key == level
                                ? Theme.of(context).primaryColor
                                : Colors.grey,
                          ),
                        ),
                      ))
                  .toList()
            ];
          },
        ),
      );
}
